<html><head><title>BindGadgetEvent</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">BindGadgetEvent()</font></b></p>
<p><b>Syntax</b></p><blockquote>
<font color="#006666"><b>BindGadgetEvent</b></font>(#Gadget, @Callback() [, EventType])  </blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Bind a gadget event to a callback. It's an additional way to handle events in PureBasic, 
which works without problem with the regulars <a href="../window/windowevent.html">WindowEvent()</a> / <a href="../window/waitwindowevent.html">WaitWindowEvent()</a> 
commands. It also allows to have real-time event notifications as 
the callback can be invoked as soon as the event occurs (useful for 
<a href="scrollbargadget.html">ScrollBarGadget()</a>, <a href="scrollareagadget.html">ScrollAreaGadget()</a> etc.). A gadget event can be unbinded with <a href="unbindgadgetevent.html">UnbindGadgetEvent()</a>. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
The gadget to bind the event to. 

</td></tr>
<tr><td><i>@Callback()</i></td>
<td> 
The callback procedure to call when the event occurs. It has to be declared like this: 
<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Procedure</font></b> <font color="#006666">EventHandler</font>()
    <font color="#006666">; Code</font>
  <b><font color="#006666">EndProcedure</font></b>
</font></pre>
Regular functions like <a href="../window/eventgadget.html">EventGadget()</a>, <a href="../window/eventwindow.html">EventWindow()</a>, <a href="../window/eventmenu.html">EventMenu()</a>, <a href="../window/eventtype.html">EventType()</a> and <a href="../window/eventdata.html">EventData()</a> are 
available within the callback to get more information about the event. 

</td></tr>
<tr><td><i>EventType (optional)</i></td>
<td> 
The event type to bind the event to. For a full list of supported types, see <a href="../window/eventtype.html">EventType()</a>. 
<font color="#924B72">#PB_All</font> can be used to bind the event to any type. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>
None.


</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Procedure</font></b> <font color="#006666">ButtonHandler</font>()
    <b><font color="#006666">Debug</font></b> "Button click event on gadget #" +<font color="#006666"> EventGadget</font>()
  <b><font color="#006666">EndProcedure</font></b>
  
<font color="#006666">  OpenWindow</font>(0, 100, 100, 200, 50, "Click test", <font color="#924B72">#PB_Window_SystemMenu</font>)
  
<font color="#006666">  ButtonGadget</font>(0, 10, 10, 180, 30, "Click me")
  
<font color="#006666">  BindGadgetEvent</font>(0, @ButtonHandler())
  
  <b><font color="#006666">Repeat</font></b>
    Event =<font color="#006666"> WaitWindowEvent</font>()
  <b><font color="#006666">Until</font></b> Event = <font color="#924B72">#PB_Event_CloseWindow</font>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>
<a href="bindgadgetevent.html">BindGadgetEvent()</a>, <a href="../menu/bindmenuevent.html">BindMenuEvent()</a>, <a href="../window/unbindevent.html">UnbindEvent()</a>, <a href="../window/windowevent.html">WindowEvent()</a>, <a href="../window/waitwindowevent.html">WaitWindowEvent()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=addgadgetitem.html>AddGadgetItem()</a> - <a href=index.html>Gadget Index</a> - <a href=buttongadget.html>ButtonGadget()</a> ->

</body></html>